<template>
  <main class="new-animation-bg" v-if="showHeader">
    <header class="header">
      <div class="header-content">
        <span class="title title-shadow">{{ title }}</span>
        <div v-if="$slots.right" class="right-action">
          <slot name="right"></slot>
        </div>
      </div>
    </header>
  </main>
</template>

<script>
export default {
  name: 'DproHeader',
  props: ['title'],
  data () {
    return {
      showHeader: false
    }
  },
  async mounted () {
    await this.$nextTick()
    this.showHeader = true
  }
}
</script>

<style scoped lang="less">
.new-animation-bg {
  position: relative;
  width: 100%;
  animation: fadeIn 2s;

  &::before {
    position: absolute;
    content: '';
    width: 319px;
    height: 1.5px;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(
      to right,
      rgba(51, 160, 255, 0) 0%,
      rgba(153, 209, 251) 50%,
      rgba(51, 160, 255, 0) 100%
    );
    //background: url("../images/card-top-line.png") no-repeat;
    //background-size: 319px 1.5px;
  }

  &::after {
    position: absolute;
    content: '';
    top: 0;
    left: -320px;
    width: 320px;
    height: 1.5px;
    background: linear-gradient(
      to right,
      rgba(51, 160, 255, 0) 0%,
      rgba(153, 209, 251) 50%,
      rgba(51, 160, 255, 0) 100%
    );
    animation: backInRight 4s linear infinite;
  }
}

.header {
  width: 100%;
  padding: 12px 0 0 4px;
  position: relative;
  box-sizing: border-box;
  animation: fadeOutLeft ease-in-out 1.5s;

  .header-content {
    display: flex;
    height: 30px;
    align-items: center;

    .title {
      line-height: 30px;
      font-size: 18px;
      color: var(--primary-text, #fff);
      font-weight: 700;
      margin-left: 14px;
      z-index: 9;
      white-space: nowrap;
    }

    &::after {
      z-index: 1;
      content: '';
      position: absolute;
      top: 12px;
      left: 4px;
      width: 220px;
      height: 30px;
      opacity: 0.3;
      background-image: linear-gradient(
        270deg,
        rgba(39, 144, 254, 0) 4%,
        rgba(28, 123, 255, 0.77) 70%,
        rgba(34, 112, 220, 0.21) 95%
      );
    }

    &::before {
      content: '';
      display: block;
      position: absolute;
      top: -4px;
      left: -56px;
      width: 220px;
      height: 86px;
      background: radial-gradient(
        rgba(120, 249, 249, 0.25),
        rgba(120, 249, 249, 0.05) 32%,
        rgba(120, 249, 249, 0) 50%
      );
    }
  }

  .right-action {
    z-index: 99;
    padding-right: 16px;
    display: flex;
    flex: 1;
    min-width: 0;
  }
}

@keyframes backInRight {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(300%);
  }
}

@keyframes fadeOutLeft {
  0% {
    opacity: 0;
    transform: translate3d(-100%, 0, 0) scale(0);
  }
  50% {
    opacity: 0.3;
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
</style>
